package com.zr.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.zr.constant.MessageConstant;
import com.zr.entity.Result;
import com.zr.pojo.Setmeal;
import com.zr.service.SetmealService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * @auther zhaorui
 * @date 2019-11-29 - 21:00
 */
@RestController
@RequestMapping("/setmeal")
public class SetmealController {


    @Reference
    private SetmealService setmealService;

    @RequestMapping("/getAllSetmeal")
    public Result getAllSetmeal(){
        try {
            List<Setmeal> setmealList = setmealService.findAllSetmeal();
            return Result.ok(MessageConstant.QUERY_SETMEALLIST_SUCCESS,setmealList);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error(MessageConstant.QUERY_SETMEALLIST_FAIL);

        }

    }


    @RequestMapping("/findById")
    public Result findById(int id){
        try {
            Setmeal setmeal = setmealService.findById(id);
            return Result.ok(MessageConstant.QUERY_SETMEAL_SUCCESS,setmeal);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error(MessageConstant.QUERY_SETMEAL_FAIL);

        }

    }


}
